clear; clc;
StdVec      =   [1 1 1 -1 -1 60 -10]'*0.01/4;
Param_0     =   struct('KAPPA',0.00/4,'XI',1/82.5/4,'Pir_SS',0.02/4,...
                                'Flag_dE',0,'Flag_Price',0,...
                                'B_Total_SS',0.91,'b_lb',-0.29,...
                                'TrProb_H',0.98,'Prob_H',0.37,...
                                'TrProb_ext',0.92,'Prob_ext',0.33,...
                                'Fin_DomShare',0.79,'Fin_AdjCost',0.8,...
                                'Cons_FracH',0.60,...
                                'RHO_M_dom',0.68,'RHO_M_ext',0.81,'RHO_Y_H',0.5,'RHO_p_F',0.90,...
                                'Taylor_Pi',1.1,'Taylor_ir',0.87,...
                                'Cons_ElasTN',6.19,'Cons_ElasHF',6.19,...
                                'Flag_wType',0);
%% Generate the Baseline Results
FileName    =   'Result_Baseline';
PP          =   Setup_PP(Param_0);
Solver_Main(PP,StdVec,'FileName',FileName);
%% Only Real Integration: Integrated share=1, No UIP
FileName    =   'Result_OnlyRealHete_1_NoUIP';
Param       =   Param_0;
Param.TrProb_ext    =   1;
Param.Prob_ext      =   1;
PP          =   Setup_PP(Param);
Solver_Main(PP,StdVec,'FileName',FileName);
%% Only Real Integration: Integrated share=1, UIP
FileName    =   'Result_OnlyRealHete_1_UIP';
Param       =   Param_0;
Param.TrProb_ext    =   1;
Param.Prob_ext      =   1;
Param.Fin_DomShare  =   0;
Param.Fin_AdjCost   =   0;
PP          =   Setup_PP(Param);
Solver_Main(PP,StdVec,'FileName',FileName);

%% Only Real Integration: Integrated share=0
FileName    =   'Result_OnlyRealHete_0';
Param       =   Param_0;
Param.TrProb_ext    =   0;
Param.Prob_ext      =   0;
PP          =   Setup_PP(Param);
Solver_Main(PP,StdVec,'FileName',FileName);
%% Only Fin Integration
FileName    =   'Result_OnlyFinHete';
Param       =   Param_0;
Param.Flag_wType    =   1;
PP          =   Setup_PP(Param);
Solver_Main(PP,StdVec,'FileName',FileName);


%% Collect results
TempList    =   {'Baseline','OnlyFinHete','OnlyRealHete_0',...
                 'OnlyRealHete_1_NoUIP','OnlyRealHete_1_UIP'};
for ii=1:length(TempList)
    vv          =   TempList{ii};
    SOLUTION    =   load(['Result_',vv,'.mat']);
    SOLUTION.IRF=   TempFun_AugIRF(SOLUTION.PP,SOLUTION.SS,SOLUTION.MODEL,SOLUTION.EquJac,SOLUTION.IRF);
    KeyResults(['TableGraphs//',vv,'//'],SOLUTION);
    Step_2_Decomposition(SOLUTION,['TableGraphs//',vv,'//']);
end
